<?php
class Zend_Form extends Base_Form
{
	
	public function getText($definition){	
		return new Zend_Element_Text($definition);
	}
	
	public function getPassword($definition){
		return new Zend_Element_Password($definition);
	}
	
	/**
    * getForm
    * Returns final form String
    */
	public function getForm(){
		$this->loadTemplate();
		
		$data = '';
		foreach($this->getElementsObj() as $element){
$data .= '		$this->form->addElement($this->get'.$element->getVariable('name').'());'. PHP_EOL;
		}
			
		$content = sprintf(self::$_tpl, $this->getOption('name'),$this->getOption('name'), $data);
			
		return $content;
	}
	
	/**
    * getBaseForm
    * Returns final base String
    */
	public function getBaseForm(){
		$this->loadBaseTemplate();
		
		$data = '';
		foreach($this->getElementsObj() as $element){
			$data .= $element->render();
		}
			
		$content = sprintf(self::$_base_tpl, $this->getOption('name'), $data);
			
		return $content;
	}
	
	protected function getElement($definition){			
		if(isset($definition['type'])){
			$class_name = 'Zend_Element_'.$definition['type'];

			if (class_exists($class_name)) {
				return new $class_name($definition);
			} else {
				//throw new Exception('Element '.$class_name.' is not found.');
				return Zend_Element_Text($definition);
			}
		} else {
			//throw new Exception('Element '.$class_name.' is not found.');
			return new Zend_Element_Text($definition);
		}
	}
	
	/**
    * getValidator
    * Returns the selected parser validator object.
    */
	protected function getValidator($name, $definition, $element){	
		$class_name = 'Zend_Validator_'.$name;
		
		if (class_exists($class_name)) {
			return new $class_name($name, $definition, $element);
		} else {
			throw new Exception('Validator '.$class_name.' is not found.');
			return null;
		}
	}
	
}
?>